# -*- coding: utf8 -*-


def head(iterable):
    it = iter(iterable)
    return next(it)


def last(iterable):
    """ don't use on infinite data structures """
    if hasattr(iterable, '__len__'):
        return iterable[len(iterable) - 1]
    *_, _last = iterable
    return _last